using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

/**
*@file       DBAccount_Login_SuccessReciever.cs
*@brief      process message DBAccount_Login_Success
*
*@author     graywind
*@version    1.0.0.1
*@data       2012/4/14
*/

//process DBAccount_Login_Success
public class OnDBAccount_Login_Success
{
    /// <summary>
    /// process message
    /// </summary>
    /// <param name="op">message operator</param>
    /// <param name="session_id">session identifier</param>
    /// <param name="msg_buffer">message buffer</param>
    /// <param name="msg_bytes">buffer length</param>
    public static void OnMapping(IMessageOperator op, Int32 session_id, byte[] msg_buffer, UInt32 msg_bytes)
    {
        //TODO
		dbserver.AccountDigestInfo digest = ProtoNet<dbserver.AccountDigestInfo>.CreateFromBytes(msg_buffer, msg_bytes);
        if (digest.LoginCode != UsrLoginManager.INVALID_CODE)
        {
            int sessionId = op.LoginManager.GetSessionId(digest.LoginCode);
            if (sessionId != NetLib.INVALID_SESSION)
            {   
				int passport = op.GeneratePassport(digest.UsrId);
                msgLSAccount_Login_Success msg = new msgLSAccount_Login_Success(sessionId, digest, passport);
                gwMessagePort.ProcessMessage(msg);
            }
        }
    }
}

//register callback
partial class MessageProcTypes<ProcType, MessageProc>
{
        [MessageProcType((int)DBServerTypes.MessageType.DBAccount_Login_Success)]
        public static DBServerProcessor.DBServerTabFunc DBAccount_Login_SuccessProc = new DBServerProcessor.DBServerTabFunc(OnDBAccount_Login_Success.OnMapping);
}
